<template>
	<view class="popular_circle_list" v-if="list.length">
		<template v-if="type == 2">
			<swiper class="swiper_list_user" autoplay="true" indicator-active-color="#494949" interval="5000" style="width:100%;height: 486rpx;">
				<swiper-item class="circle_i" v-for="(val, key) in list" :key="key">
					<!-- <view class="circles_item" v-for="(item, index) in val" :key="index" @click="getCircleInfo(item.id)">
						<view class="circles_item_info">
							<view class="circles_item_title">{{item.title}}</view>
							<view class="circles_item_gz">
								<image class="circles_item_gz_icon" :src="domain + '/uploads/default/20230628/2c7d68b982302e32ccfa8c0a3d922319.png'" />
								<view  class="circles_item_gz_num">{{item.user_circle_count}}粉丝</view>
							</view>
							<view class="circles_item_gz_user" v-if="item.user_circle.length">
								<image class="circles_item_gz_avatar" v-for="(a,b) in item.user_circle" :key="b" :src="a.user.avatar || '/static/images/f.png'" />
								<image class="circles_item_gz_avatar" :src="domain + '/uploads/default/20230629/436303b1fccbd3e1714b11990d5b7e28.png'" />
								<view class="circles_item_gz_tl">{{item.circle_community_count}} 人在讨论</view>
							</view>
						</view>
						<view class="circles_item_avatar">
							<image :src="item.avatar" />
						</view>
					</view> -->
					<view v-for="(item, index) in val" :key="index" class="circle-item">
						<view class='circle-item-avatar'>
							<view class="unread-message">99+</view>
							<image :src="item.avatar" />
						</view>
						<view class='circle-item-info'>
							<view class="circle-item-infos">
								<view class="circle-item-left">
									<view class='circle-item-title line1'>{{item.title}}</view>
									<view class="circle-item-gz">
										<image class="circle-item-gz-icon" :src="domain + '/uploads/default/20230628/2c7d68b982302e32ccfa8c0a3d922319.png'" />
										<view  class="circle-item-gz-num">{{item.user_circle_count}}粉丝</view>
									</view>
								</view>
								<view class='circle-item-button'>
									<view class="circle-item-button_btn" :class="item.is_user_circle ? 'is_user_circle' : ''" @click="getCircleInfo(item.id)">{{item.is_user_circle ? '进群' : '加群'}}</view>
								</view>
							</view>
							<view class="circle-item-gz-user" v-if="item.user_circle.length">
								<image class="circle-item-gz-avatar" v-for="(v,i) in item.user_circle" :key="i" :src="v.user.avatar || '/static/images/f.png'" />
								<image class="circle-item-gz-avatar" :src="domain + '/uploads/default/20230629/436303b1fccbd3e1714b11990d5b7e28.png'" />
								<view class="circle-item-gz-tl">{{item.circle_community_count}} 人在讨论</view>
							</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
		</template>
		<template v-else>
			<view v-for="(item, index) in list" :key="index" class="circle-item">
				<view class='circle-item-avatar'>
					<view class="unread-message">99+</view>
					<image :src="item.avatar" />
				</view>
				<view class='circle-item-info'>
					<view class='circle-item-title'>{{item.title}}</view>
					<view class="circle-item-gz">
						<image class="circle-item-gz-icon" :src="domain + '/uploads/default/20230628/2c7d68b982302e32ccfa8c0a3d922319.png'" />
						<view  class="circle-item-gz-num">{{item.user_circle_count}}粉丝</view>
					</view>
					<view class="circle-item-gz-user" v-if="item.user_circle.length">
						<image class="circle-item-gz-avatar" v-for="(v,i) in item.user_circle" :key="i" :src="v.user.avatar || '/static/images/f.png'" />
						<image class="circle-item-gz-avatar" :src="domain + '/uploads/default/20230629/436303b1fccbd3e1714b11990d5b7e28.png'" />
						<view class="circle-item-gz-tl">{{item.circle_community_count}} 人在讨论</view>
					</view>
				</view>
				<view class='circle-item-button'>
					<view class="circle-item-button_btn" @click="getCircleInfo(item.id)">加入</view>
				</view>
			</view>
		</template>
	</view>
</template>

<script>
	import { mapGetters } from "vuex";
	import { configMap } from '@/utils';
	import { HTTP_REQUEST_URL } from '@/config/app';
	import { getAttentionCircle } from '@/api/circle.js';
	export default {
		components: {
		},
		data() {
			return {
				domain: HTTP_REQUEST_URL,
			}
		},
		props: {
			list: {
				type: Array|Object,
				default: () => []
			},
			type: {
				type: Number,
				default: 1,
			},
		},
		computed: configMap(['hide_mer_status'], mapGetters(['isLogin','viewColor','keyColor'])),
		created() {
		},
		methods: {
			getCircleInfo(circle_id) {
				let that = this;
				if(!that.isLogin) return that.$util.Tips({title: '请先登录'}, {
					tab: 1,
					url: '/pages/user/index'
				})
				getAttentionCircle(circle_id).then(res=>{
					if(res.status == 200 && res.data.pay_type){
						return that.$util.Tips('/pages/extends/circle_create/circle_info?id='+circle_id)
					}
					return that.$util.Tips('/pages/extends/circle_create/circle_pay?id='+circle_id);
				}).catch(err=>{
					that.$util.Tips({title: err});
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.circle-item {
		display: flex;
		margin: 10rpx 10rpx 0;
		padding: 20rpx;
		background-color: #fff;
		.circle-item-avatar {
			position: relative;
			.unread-message {
				position: absolute;
				right: -6px;
				top: -6px;
				width: 40rpx;
				height: 40rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				background: #FB2C26;
				border-radius: 50%;
				font-size: 20rpx;
				z-index: 1;
			}
			image{
				width: 120rpx;
				height: 120rpx;
			}
		}
		.circle-item-info {
			flex: 1;
			margin-left: 20rpx;
			padding-top: 10rpx;
			overflow: hidden;
			.circle-item-infos {
				display: flex;
				.circle-item-left {
					overflow: hidden;
				}
			}
			.circle-item-title {
				font-size: 36rpx;
				font-weight: bold;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}
			.circle-item-label_name {
				margin-top: 10rpx;
				font-size: 30rpx;
			}
		}
		.circle-item-button {
			margin-left: auto;
			display: flex;
			align-items: center;
			white-space: nowrap;
			.circle-item-button_btn {
				font-size: 36rpx;
				font-weight: bold;
				padding: 20rpx 30rpx;
				background-color: #F2F63C;
				border-radius: 40rpx;
			}
		}
	}
	.circle-item {
		display: flex;
		// margin: 10rpx 10rpx 0;
		padding: 30rpx;
		background-color: #fff;
		margin-top: 20rpx;
		.circle-item-avatar {
			position: relative;
			.unread-message {
				position: absolute;
				right: -6px;
				top: -6px;
				width: 40rpx;
				height: 40rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				background: #FB2C26;
				border-radius: 50%;
				font-size: 20rpx;
				z-index: 1;
			}
			image{
				width: 160rpx;
				height: 160rpx;
			}
		} 
		.circle-item-info {
			flex: 1;
			margin-left: 20rpx;
			padding-top: 10rpx;
			overflow: hidden;
			.circle-item-title {
				font-size: 36rpx;
				font-weight: bold;
				color: #323232;
				line-height: 44rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}
			.circle-item-label_name {
				margin-top: 10rpx;
				    font-size: 24rpx;
			}
			.circle-item-gz {
				display: flex;
				align-items: center;
				margin-top: 12rpx;
				.circle-item-gz-icon {
					width: 28rpx;
					height: 28rpx;
				}
				.circle-item-gz-num {
					font-size: 28rpx;
					font-weight: 400;
					color: #323232;
					line-height: 34rpx;
					margin-left: 4rpx;
				}
			}
			.circle-item-gz-user {
				display: flex;
				align-items: center;
				margin-top: 20rpx;
				image {
					width: 44rpx;
					height: 44rpx;
					border-radius: 100%;
					margin-left: -10rpx;
				}
				image:first-child {
					margin-left: 0rpx;
				}
			}
			.circle-item-gz-tl {
				font-size: 28rpx;
				font-weight: 400;
				color: #323232;
				line-height: 28rpx;
				margin-left: 10rpx;
			}
		}
		.circle-item-button {
			margin-left: auto;
			display: flex;
			align-items: center;
			.circle-item-button_btn {
				font-size: 30rpx;
				font-weight: 500;
				color: #1C211D;
				line-height: 42rpx;
				background: #F2F63C;
				border-radius: 37rpx;
				padding: 16rpx 42rpx;
				font-weight: bold;
			}
			.is_user_circle {
				background-color: #53BB47;
				color: #030502;
			}
		}
	}
.circle_i {
	// display: grid;
	grid-gap: 20rpx;
	// margin-right: 20rpx;
}
.circles_item {
	// width: 510rpx;
	height: 220rpx;
	background: #FFFFFF;
	border-radius: 12rpx;
	padding: 30rpx;
	display: flex;
	flex-wrap: nowrap;
	overflow: hidden;
	margin-bottom: 30rpx;
	box-shadow: 4rpx 4rpx 16rpx 0rpx rgba(125, 124, 116, 0.5);
	.circles_item_info {
		flex: 1;
		.circles_item_title {
			font-size: 36rpx;
			font-weight: bold;
			color: #323232;
			line-height: 44rpx;
		}
		.circles_item_gz {
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			margin-top: 12rpx;
			image {
				width: 28rpx;
				height: 28rpx;
			}
			.circles_item_gz_num {
				font-size: 32rpx;
				font-weight: 400;
				color: #323232;
				line-height: 34rpx;
				margin-left: 8rpx;
			}
		}
		.circles_item_gz_user {
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			margin-top: 20rpx;
			image {
				width: 44rpx;
				height: 44rpx;
				border-radius: 50%;
				margin-left: -10rpx;
			}
			image:first-child {
				margin-left: 0;
			}
			.circles_item_gz_tl {
				margin-left: 10rpx;
				font-size: 20rpx;
				font-weight: 400;
				color: #323232;
				line-height: 28rpx;
				margin-left: 10rpx;
			}
		}
	}
	.circles_item_avatar {
		width: 160rpx;
		height:160rpx;
		image {
			width: 160rpx;
			height:160rpx;
			border-radius: 16rpx;
		}
	}
}
.swiper_list_user {
	.circle-item {
		margin-top: 0;
		margin-bottom: 15rpx;
		border-radius: 10rpx;
		box-shadow: 4rpx 4rpx 16rpx 0rpx rgba(125, 124, 116, 0.5);
	}
}
</style>